package xx.iverson.util;

import lombok.extern.slf4j.Slf4j;

import java.util.Random;
import java.util.UUID;

/**
 * xx.iverson.util.SequenceGenUtil
 * 生成唯一ID以及昵称
 * on 2025/6/18-下午3:06
 *
 * @author weijx
 */
@Slf4j
public class SequenceGenUtil {

    /**
     * 获取唯一ID
     */
    public static String getKey() {
        return UUID.randomUUID().toString().replace("-", "");
    }

    /**
     * 获取随机昵称
     */
    public static String generateRandomString() {
        String prefix = "cest_";
        int length = 6 + new Random().nextInt(5);

        // 所有可能的字符：0-9, A-Z, a-z
        String chars = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
        Random random = new Random();

        StringBuilder sb = new StringBuilder(prefix);
        for (int i = 0; i < length; i++) {
            int randomIndex = random.nextInt(chars.length());
            sb.append(chars.charAt(randomIndex));
        }

        return sb.toString();
    }
}